package com.hsmw.api.controller.forman;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hsmw.api.service.HsmwComplainService;
import com.hsmw.common.base.BasePage;
import com.htn.common.core.base.DataResponse;
import com.htn.common.core.constant.CommonConstants;
import com.htn.common.core.utils.StringUtils;
import com.hsmw.domain.HsmwComplain;
import com.hsmw.domain.HsmwReport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.hsmw.common.base.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 投诉信息表 前端控制器
 * </p>
 *
 * @author tjy
 * @since 2021-08-04
 */
@Api(tags = "投诉")
@RestController
@RequestMapping("/hsmw/complain")
public class HsmwComplainController extends BaseController<HsmwComplainService, HsmwComplain>{

    @Autowired
    private HsmwComplainService hsmwComplainService;


    @ApiOperation(value = "查看投诉信息的分页",notes = "查看投诉信息的分页",produces = "application/json")
    @PostMapping("/findComplainList")
    public DataResponse findComplainList(@RequestBody @Valid BasePage<HsmwComplain> basePage){
        IPage page = new Page(basePage.getPageNo(), basePage.getPageSize());
        HsmwComplain hsmwComplain = basePage.getRequestData();
        return new DataResponse(hsmwComplainService.findComplainList(page,hsmwComplain));
    }




    @ApiOperation(value = "修改投诉状态 已确认 已解决 已回访 已关闭",notes = "修改投诉状态 已确认 已解决 已回访 以关闭",produces = "application/json")
    @PostMapping("updateComplainStatus")
    public DataResponse updateComplainStatus(@RequestBody HsmwComplain hsmwComplain){

        if(StringUtils.isNull(hsmwComplain)){
            return new DataResponse(CommonConstants.ResponseStatus.FAIL,"传递参数错误");
        }
        hsmwComplainService.updateComplainStatus(hsmwComplain);
        return new DataResponse(CommonConstants.ResponseStatus.SUCCESS);
    }


    @ApiOperation(value = "根据id查询投诉详情",notes = "根据id查询投诉详情",produces = "application/json")
    @ApiImplicitParam(name = "id",value = "投诉id",dataType = "String")
    @PostMapping("findComplainInfoById")
    public DataResponse findComplainInfoById(String id){

        if(StringUtils.isEmpty(id)){
            return new DataResponse(CommonConstants.ResponseStatus.FAIL,"传递参数错误");
        }
        return new DataResponse(hsmwComplainService.findComplainInfoById(id));
    }


}

